﻿
using IHISCETeim.BLL;
using IHISCETeim.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using IHISCETeim.Library;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Newtonsoft.Json;

namespace IHISCETeim.Web.AgentSys.SvrMgr
{
    public partial class AgentQltyView2 : AgentPageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.查看 };
            }
        }
        protected override string DWZRef
        {
            get { return "AgentQltyList"; }
        }

        protected int QltyId
        {
            get
            {

                return GetRequestValue<int>("QltyId", 0);
            }
        }

        private AgentQltyInfo _objFx = null;

        public AgentQltyInfo obj
        {
            get
            {
                if (_objFx == null)
                    _objFx = AgentQltyController.GetByQltyId(QltyId);
                return _objFx;
            }
        }
        protected string GetSvrInfo()
        {
            OUserInfo svrUser = OUserController.GetById(obj.SrvActUserId);
            return string.Format("{0} {1}", svrUser.RealName, svrUser.Mobile);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            //JsonConvert.SerializeObject(obj)
            LoadInfo();
        }

        private void LoadInfo()
        {
            try {
                List<AgentQltyImgInfo> listImg = AgentQltyController.GetAllImgByQltyId_0(QltyId);
                List<AgentQltyImgInfo> listImgT = new List<AgentQltyImgInfo>();
                for (int i = 0; i < 6; i++)
                {
                    listImgT.Add(listImg[i]);
                }



                this.rpImgs.DataSource = listImgT;
                this.rpImgs.DataBind();
            
                this.otherFileDownLoad.NavigateUrl = listImg[6].IMGRelatively;
                this.otherFileDownLoad.Enabled = !string.IsNullOrEmpty(listImg[6].IMGRelatively);
                //
                listImg = AgentQltyController.GetAllImgByQltyId_2(QltyId);
                listImgT = new List<AgentQltyImgInfo>();
                for (int i = 0; i < 2; i++)
                {
                    listImgT.Add(listImg[i]);
                }

                this.SvrResultImgrp.DataSource = listImgT;
                this.SvrResultImgrp.DataBind();

                this.SvrResultImg3HL.NavigateUrl = listImg[2].IMGRelatively;
                this.SvrResultImg3HL.Enabled = !string.IsNullOrEmpty(listImg[2].IMGRelatively);
            }
            catch
            {

            }

            List<AgentQltyPartsInfo> listParts = AgentQltyController.GetAllPartsByQltyId(QltyId);

            this.rpParts.DataSource = listParts;
            this.rpParts.DataBind();
            //
            this.rpReject.DataSource = AgentQltyController.AgentQltyReject_GetAllByQltyId(QltyId);
            this.rpReject.DataBind();
        }
    }
}